package org.apache.dubbo.demo.provider;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServerMain;

/**
 * @author liangcai_zhu
 * @Description TODO
 * @Date 2019/12/13 10:51
 */
public class EmbedZookeeper {

  public static void main(String[] args) {
    System.out.println("启动内嵌zookeeper");
    //内嵌zookeeper服务器
    ZooKeeperServerMain serverMain = new ZooKeeperServerMain();
    ServerConfig config = new ServerConfig();
    String userdir = System.getProperty("user.dir");
    config.parse(new String[]{"2181", userdir+ "/zoo_data/"});
    System.out.println("zookeeper启动成功");
    try {
      serverMain.runFromConfig(config);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
